package com.huyirong.aicode.exception;

import lombok.Getter;

@Getter
///lombok自定义注解，自动生成get、set方法
public class BusinessException extends RuntimeException{
    /**
     * 错误码
     */
    private final int code;

    //注:RuntimeException自己有message这个字段
    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public BusinessException(ErrorCode errorCode, String message) {
        super(message);
        this.code = errorCode.getCode();
    }

}
